home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 125 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.9 KB  |  72 lines

  1. Newsgroups: comp.std.c++
  2. Path: cs.mu.OZ.AU!bounce-back
  3. From: Nathan Myers <ncm@cantrip.org>
  4. Subject: Allocator pointer operations (was: STL experts, please comment)
  5. Message-ID: <31058136.611@cantrip.org>
  6. Originator: fjh@munta.cs.mu.OZ.AU
  7. Sender: news@cs.mu.OZ.AU (CS-Usenet)
  8. Organization: Best Internet Communications
  9. References: <4dnteb$6fo@news.bridge.net> <4e1034$5ar@hermes.synopsys.com>
  10. X-Original-Date: Tue, 23 Jan 1996 16: 45:42 -0800
  11. Date: Wed, 24 Jan 1996 01:03:19 GMT
  12. Approved: fjh@cs.mu.oz.au
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMQWFZ+EDnX0m9pzZAQFhogF9HEIcgLc3j4BA5wEnDTBkJfVEE7flritH
  15.     L9KWdK9cVzG451QquQLkeMyQdjyXX8Qc
  16.     =Eigt
  17. X-Mailer: Mozilla 2.0b3 (X11; I; SunOS 5.4 sun4m)
  18.  
  19. Joe Buck wrote:
  20. > David Byrden <100101.2547@compuserve.com> writes:
  21. > >In the HP STL, deque::iterator has a default ctor which initialises
  22. > >several of its members with the value 0
  23. > >
  24. > >       iterator() : current(0), first(0), last(0), node(0) {}
  25. > >
  26. > >These members have the type deque::pointer, which is a typedef
  27. > >for the pointer in deque's allocator.
  28. > >An allocator pointer, according to the standard, has exactly the same
  29. > >semantics as a random access iterator.
  30.  
  31. No... an allocator pointer is something that has pointer semantics.
  32. It can only confuse things to bring in Iterators here.  The list of
  33. required semantics for allocator pointers is quite limited.
  34.  
  35. Conversion from 0 is not required, but conversion to void* and
  36. default construction are.  Arguably the line above should be:
  37.  
  38. > >       iterator() : current(Allocator::pointer()),
  39.                        first(Allocator::pointer()), 
  40.                        last(Allocator::pointer()),
  41.                        node(Allocator::pointer()) {}
  42.  
  43. > >I can find no place where it says that all random access iterators
  44. > >should be constructable from the int value zero, neither in
  45. > >documentation from the time of the HP STL, nor the latest draft standard.
  46. > Correct.
  47.  
  48. > >So, this ctor seems to break the rules. Yet it was written by the
  49. > >inventors of STL.
  50. > Well, they goofed, I suppose.  Seems the types of allocators they used
  51. > were all pointers, so they didn't test out other cases.
  52.  
  53. The current definition of allocator pointers didn't exist when 
  54. the HP implementation was written, so you can't blame Stepanov
  55. and Lee.  
  56.  
  57. The implementations of all the standard containers change in response
  58. to changes in Allocator, and std lib vendors have been working feverishly
  59. to get everything consistent.  A non-pointer allocator "pointer" is an
  60. obvious addition to the test suite for a standard library.
  61.  
  62. Nathan Myers
  63. http://www.cantrip.org/          <-- note: new site
  64. ncm@cantrip.org                  <-- note: new address
  65. ---
  66. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  67.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  68.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  69.